<?php echo $header; ?>

<div id="content">
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>

    <?php if ($error_warning) { ?>
        <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
    <?php if ($success) { ?>
        <div class="success"><?php echo $success; ?></div>
    <?php } ?>

    <div class="box">
        <div class="heading">
            <h1><img src="view/image/delivery.png" alt="" /> <?php echo $heading_title; ?></h1>
            <div class="buttons"><a href="<?php echo $insert; ?>" class="button"><?php echo $button_insert; ?></a><a onclick="$('#form').attr('action', '<?php echo $delete; ?>'); $('#form').attr('target', '_self'); $('#form').submit();" class="button"><?php echo $button_delete; ?></a></div>
        </div>
        <div class="content">
            <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form">
                <table class="list">
                    <thead>
                        <tr>
                            <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
                            <td class="left" width="100">
                                <?php if ($sort == 'delivery_id') { ?>
                                    <a href="<?php echo $sort_id; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_id; ?></a>
                                <?php } else { ?>
                                    <a href="<?php echo $sort_id; ?>"><?php echo $column_id; ?></a>
                                <?php } ?>
                            </td>
                            <td class="left">
                                <?php if ($sort == 'city') { ?>
                                    <a href="<?php echo $sort_city; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_city; ?></a>
                                <?php } else { ?>
                                    <a href="<?php echo $sort_city; ?>"><?php echo $column_city; ?></a>
                                <?php } ?>
                            </td>
                            <td class="left">
                                <?php if ($sort == 'price') { ?>
                                    <a href="<?php echo $sort_price; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_price; ?></a>
                                <?php } else { ?>
                                    <a href="<?php echo $sort_price; ?>"><?php echo $column_price; ?></a>
                                <?php } ?>
                            </td>
                            <td class="right"><?php echo $column_action; ?></td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="filter">
                            <td></td>
                            <td></td>
                            <td><input type="text" name="filter_city" value="<?php echo $filter_city ?>" /></td>
                            <td><input type="text" name="filter_price" value="<?php echo $filter_price ?>" /></td>
                            <td align="right"><a onclick="filter();" class="button"><?php echo $button_filter; ?></a></td>
                        </tr>
                        <?php if ($delivery_list) { ?>
                            <?php foreach ($delivery_list as $delivery) { ?>
                                <tr>
                                    <td><input type="checkbox" name="selected[]" value="<?php echo $delivery['delivery_id']; ?>" /></td>
                                    <td class="left"><?php echo $delivery['delivery_id']; ?></td>
                                    <td class="left"><?php echo $delivery['city']; ?></td>
                                    <td class="left"><?php echo $delivery['price']; ?></td>
                                    <td class="right">
                                        <?php foreach ($delivery['action'] as $action) { ?>
                                            [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        <?php } else { ?>
                            <tr>
                                <td class="center" colspan="5"><?php echo $text_no_results; ?></td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </form>
            <div class="pagination"><?php echo $pagination; ?></div>
        </div>
    </div>
</div>

<script type="text/javascript"><!--
    function filter() {
        url = '<?php echo $filter_url; ?>&token=<?php echo $token ?>';

        var filter_city = $('input[name=\'filter_city\']').attr('value');
        if (filter_city) {
            url += '&filter_city=' + encodeURIComponent(filter_city);
        }

        var filter_price = $('input[name=\'filter_price\']').attr('value');
        if (filter_price) {
            url += '&filter_price=' + encodeURIComponent(filter_price);
        }

        window.location = url;
    }
//--></script>

<?php echo $footer; ?>